<template>
  <!-- 新技术 -->
  <a-select
    v-model="currentValue"
    v-bind="$attrs"
    allow-clear
    v-on="$listeners"
  >
    <a-spin
      v-if="fetching"
      slot="notFoundContent"
      size="small"
    />
    <a-select-option
      v-for="i in list"
      v-else
      :key="i.technicalId"
      :value="i.technicalId"
    >
      {{ i.technicalName }}
    </a-select-option>
  </a-select>
</template>
<script>
import { getTechnologyTemplate} from '@/api/technology'

export default {
  inheritAttrs: false,
  props: {
    // v-model绑定的数据
    value: {
      type: [Array, String],
    },
    // 需要联动的表单名，
    form: {
      type: Object,
      default: function () {
        return {}
      },
    },
  },
  data() {
    return {
      fetching: false,
      list: [],
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      this.fetching = true
      getTechnologyTemplate(null,{pageNo:1,pageSize:10000})
        .then((res) => {
          this.fetching = false
          if (res.code === 200) {
            this.list = res.data
          } else {
            this.$message.error('err:', res.message)
          }
        })
        .catch((res) => {
          this.fetching = false
        })
    },
  },
  computed: {
    // 转换绑定的选中数据，与v-model同步
    currentValue: {
      get: function () {
        return this.value
      },
      set: function (value) {
        this.$emit('input', value)
      },
    },
  }
}
</script>
